import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Test {
    public static  boolean  lex(String[] str)
    {
        for(int i=0;i<str.length-1;i++)
        {
            if(str[i+1].compareTo(str[i])>0)
            {
                return false;
            }
        }
        return true;
    }
    public static boolean  len(String[] str)
    {
        for(int i=0;i<str.length-1;i++)
        {
            if(str[i].length()>str[i+1].length())
            {
                return false;
            }
        }
        return true;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String[] str = new String[n];
        for (int i = 0; i < n; i++) {
            str[i] = in.next();
        }
        boolean s1=lex(str);
        boolean s2=len(str);
        if(s1&&s2)
        {
            System.out.println("both");
        }
        else if(s1)
        {
            System.out.println("lexicographically");
        }
        else if(s2)
        {
            System.out.println("lengths");
        }
        else {
            System.out.println("none");
        }
    }
}